package com.orangelife.mobile.parkingcard.bean;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import java.util.List;
import java.util.Map;

public class ParkingInfomation {

    private static String community;

    private static String building;

    private static String room;

    private static String name;

    private static String commID;

    private static String apartmentID;

    private static int usedParkingSpaces;

    private static int totalParkingSpaces;

    private static List<Map<String, Object>> listUsed;

    private static List<Map<String, Object>> listTotal;

    private static List<Map<String, Object>> listPublic;

    private static String ownerID;

    private static int type;

    private static SharedPreferences sp;

    private static SharedPreferences getSharedPreference(Context context) {

        if (sp == null) {
            sp = context.getSharedPreferences("parking_card", Context.MODE_PRIVATE);
        }
        return sp;
    }

    public static int getType() {
        return type;
    }

    public static void setType(int type) {
        ParkingInfomation.type = type;
    }

    public static List<Map<String, Object>> getListPublic() {
        return listPublic;
    }

    public static void setListPublic(List<Map<String, Object>> listPublic) {
        ParkingInfomation.listPublic = listPublic;
    }

    public static String getApartmentID(Context context) {
        getSharedPreference(context);
        return sp.getString("apartmentID", "");
    }

    public static List<Map<String, Object>> getListTotal() {
        return listTotal;
    }

    public static void setOwnerID(String ownerID) {
        ParkingInfomation.ownerID = ownerID;
    }

    public static String getOwnerID(){
        return ownerID;
    }

    public static void setListTotal(List<Map<String, Object>> listTotal) {
        ParkingInfomation.listTotal = listTotal;
    }

    public static List<Map<String, Object>> getListUsed() {
        return listUsed;
    }

    public static void setListUsed(List<Map<String, Object>> listUsed) {
        ParkingInfomation.listUsed = listUsed;
    }

    public static int getTotalParkingSpaces() {
        return totalParkingSpaces;
    }

    public static void setTotalParkingSpaces(int totalParkingSpaces) {
        ParkingInfomation.totalParkingSpaces = totalParkingSpaces;
    }

    public static int getUsedParkingSpaces() {
        return usedParkingSpaces;
    }

    public static void setUsedParkingSpaces(int usedParkingSpaces) {
        ParkingInfomation.usedParkingSpaces = usedParkingSpaces;
    }

    public static void setApartmentID(String apartmentID, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("apartmentID", apartmentID);
        editor.commit();
    }

    public static String getCommID(Context context) {
        getSharedPreference(context);
        return sp.getString("commID", "");
    }

    public static void setCommID(String commID, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("commID", commID);
        editor.commit();
    }

    public static String getBuilding(Context context) {
        getSharedPreference(context);
        return sp.getString("building", "");
    }

    public static void setBuilding(String building, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("building", building);
        editor.commit();
    }

    public static String getCommunity(Context context) {
        getSharedPreference(context);
        return sp.getString("community", "");
    }

    public static void setCommunity(String community, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("community", community);
        editor.commit();
    }

    public static String getRoom(Context context) {
        getSharedPreference(context);
        return sp.getString("room", "");
    }

    public static void setRoom(String room, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("room", room);
        editor.commit();
    }

    public static String getName(Context context) {
        getSharedPreference(context);
        return sp.getString("name", "");
    }

    public static void setName(String name, Context context) {
        sp = getSharedPreference(context);
        Editor editor = sp.edit();
        editor.putString("name", name);
        editor.commit();
    }


}
